package com.lzh.others.basejava.Thread_21.bilibili_course_thread.CompletableFuturePrac_07;

import com.lzh.others.basejava.Thread_21.utils.SmallTool;

import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;

/**
 * @author LiuZiHao
 * @date 创建时间:2023年05月22日 10:18:13
 */
public class CompletableFuturePrac_07_old {
    public static void main(String[] args) {
        SmallTool.printTimeAndThread("小白和小伙伴们 进餐厅点菜了");
        long startTime = System.currentTimeMillis();

        ArrayList<Dish> dishes = new ArrayList<>();
        //点菜
        for (int i = 0; i < 10; i++) {
            Dish dish = new Dish("菜" + i, 1);
            dishes.add(dish);
        }
        //做菜
        for (Dish dish : dishes) {
            CompletableFuture.runAsync(dish::make).join();
        }
        SmallTool.printTimeAndThread("菜都做好了,上桌" + (System.currentTimeMillis() - startTime) / 1000);

    }

}
